layui.use(['jquery','laydate','layer','form','table'],function () {
    var $ = layui.jquery;
    var laydate = layui.laydate;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;

    laydate.render({
        elem:'#unsealDate',
        type:'date'
    })

    var Unseal = table.render({
        elem:'#root',
        url:"/newJurisdiction/getUnsealingLog?",
        toolbar:"#toptool",
        page:true,
        limit:10,
        limits:[10,15,20],
        size: 'lg',
        cols:[
            [
                {type:"checkbox",align:"center"},
                {type:"numbers",title:"序号",align:"center"},
                {field:"account",title:"账户名称",align:"center"},
                {field:"deptName",title:"部门名称",align:"center"},
                {field:"type",title:"用户类型",align:"center",templet:function (data) {
                    console.log(data);
                    if(data.type=3){
                            return "后台用户";
                    }else if(data.type=2){
                        return "前台用户";
                    }else{
                        return "非进思用户";
                    }
                }},
                {field:"unsealDate",title:"解封时间",align:"center"},
                {title:"操作",align:"center",templet:function (data) {
                    return "<div>"+"<a href='javascript:details(" + data.userId + ");' style='color: #2F4056;;margin-right: 10px'>查看</a>"+"</div>";
                }}
            ]
        ]
    });

    /* 查看用户开始 */
    details = function details(id) {
        $.ajax({
            type: "post",
            dataType: "json",
            data: {"id": id},
            url: "/newJurisdiction/getUserById",
            success: function (data) {
                devicesMsg(data);
            }
        })
    };

    /*查看页面赋值*/
    function devicesMsg(data) {
        var obj;
        layer.open({
            type: 2,
            shode: 0,
            maxmin: true,
            title: "查看用户信息",
            content: "/newquan/newquan-user-see.html",
            area: ["1000px", "620px"],
            btn: ["关闭"],
            yes: function (index) {
                layer.close(index);
            }, success: function (layero, index) {
                obj = layero.find('iframe').contents();
                obj.find("#acatarUrl").attr('src', "http://"+data.data.acatarUrl);
                obj.find("#account").val(data.data.account);
                obj.find("#trueName").val(data.data.trueName);
                obj.find("#sex").val(data.data.sex);
                obj.find("#phone").val(data.data.phone);
                obj.find("#birthDate").val(data.data.birthDate);
                obj.find("#deptName").val(data.data.deptName);
                obj.find("#registerDate").val(data.data.registerDate);
                obj.find("#registerIp").val(data.data.registerIp);
                obj.find("#email").val(data.data.email);
                obj.find("#freestyle").val(data.data.freestyle);
            }
        });
    };

    /*条件查询*/
    form.on('submit(sub)', function (data) {
        var account = $('#account').val();
        var unsealDate = $('#unsealDate').val();
        var deptName = $('#deptName').val();
        Unseal.reload({
            url: "/newJurisdiction/getUnsealingLog?account="+account+"&deptName="+deptName+"&unsealDate="+unsealDate,
        });
        return;
    });

    /* 重置开始 */
    form.on('submit(subs)', function () {
        Unseal.reload({
            url: "/jurisdiction/getPeopleUnsealing",
        });
    });

    /* 返回 */
    goBack = function goBack() {
        parent.$('#Jump').val('首页');
        parent.getQuick();
        return;
    }

    /* 刷新 */
    Refresh = function Refresh() {
        location.reload();
    };
});